package com.hawk.eye.framework.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.handler.TenantLineHandler;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
import com.hawk.eye.framework.utils.SecurityUtils;
import lombok.AllArgsConstructor;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.StringValue;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.Assert;

/**
 * @className: MybatisPlusConfiguration
 * @description:
 * @author: salad
 * @date: 2022/10/9
 **/
@AllArgsConstructor
@Configuration
public class MybatisPlusConfiguration {


    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
//
//    @Bean
//    public TenantLineHandler tenantLineHandler() {
//        return () -> new StringValue(SecurityUtils.getTenantId());
//    }
//
//    @Bean
//    public TenantLineInnerInterceptor tenantLineInnerInterceptor(TenantLineHandler tenantLineHandler) {
//        TenantLineInnerInterceptor interceptor = new TenantLineInnerInterceptor();
//        interceptor.setTenantLineHandler(tenantLineHandler);
//        return interceptor;
//    }

}
